package com.shop.loan.model;

import com.shop.loan.handler.BlackListUploadHandler;
import com.shop.loan.model.vo.BlackListUploadVo;
import com.shop.loan.proxy.BlackListProxy;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_erupt.RowOperation;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.upms.model.EruptUserVo;

import javax.persistence.*;
import java.util.Date;

@Setter
@Getter
@Erupt(
        name = "黑名单列表",
        power = @Power(edit = false, viewDetails = false),
        dataProxy = BlackListProxy.class,
        orderBy = "id desc",
        rowOperation = {
                @RowOperation(
                        title = "批量上传",
                        icon = "fa fa-plus",
                        mode = RowOperation.Mode.BUTTON,
                        eruptClass = BlackListUploadVo.class,
                        operationHandler = BlackListUploadHandler.class
                )
        }
)
@Table(name = "s_blacklist")
@Entity
public class BlackList extends BaseModel {


    @EruptField(
            views = @View(title = "类型"),
            edit = @Edit(
                    title = "类型",
                    type = EditType.CHOICE,
                    search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "ip", value = "1"),
                                    @VL(label = "手机号", value = "2"),
                                    @VL(label = "身份证号码", value = "3"),
                                    @VL(label = "姓名", value = "4"),
                            }
                    ))
    )
    private Integer type;

    @EruptField(
            views = @View(title = "内容"),
            edit = @Edit(
                    title = "内容",
                    search = @Search,
                    notNull = true
            )
    )
    private String content;

    @EruptField(
            views = @View(title = "原因"),
            edit = @Edit(title = "原因")
    )
    private String reason;


    @EruptField(
            views = @View(title = "时间"),
            edit = @Edit(title = "时间",
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date createTime;


    @ManyToOne
    @EruptField(
            views = @View(title = "添加人", column = "name"),
            edit = @Edit(
                    title = "添加人",
                    readonly = @Readonly,
                    type = EditType.REFERENCE_TREE
            )
    )
    @JoinColumn(name = "create_user_id")
    private EruptUserVo createUser;

}
